Table 2–7: 4GL string manipulation functions
|
Function
|
Arguments
|
Returned value
|
|
FILL
|
expression AS CHAR, repeat-count AS INTEGER
|
CHARACTER — A character string made up of the expression repeated repeat-count times.
|
|
INDEX
|
source AS CHAR, target AS CHAR, starting-point AS INTEGER
|
INTEGER — The position of the first occurrence of the target string within the source string, relative to the starting-point. The starting-point is optional and defaults to 1 (the beginning of the string).
|
|
LEFT-TRIM
|
string AS CHAR, trim-chars AS CHAR
|
CHARACTER — The input string, with the trim-chars removed from the beginning of the string. The trim-chars argument is optional, and defaults to any white space (spaces, tabs, carriage returns, and line feeds).
|
|
LENGTH
|
string AS CHAR, type AS CHAR
|
INTEGER — The number of characters, bytes, or columns in the string. The type is optional and defaults to CHARACTER. Other possible values for this argument are RAW, which makes the function return the number of bytes in the string, and COLUMN, which causes it to return the number of display or print character-columns. These latter two types are useful for manipulating strings that might contain double-byte characters representing characters in non-European languages.
|
|
R-INDEX
|
source AS CHAR, target AS CHAR, starting-point AS INTEGER
|
INTEGER — The position of the target string within the source string, but with the search starting at the end of the string rather than the beginning. The position, however, is counted starting at the left. This function is useful for returning the right-most (last) occurrence of the source substring. The starting-point is optional and defaults to 1.
|
|
REPLACE
|
source AS CHAR, from-string AS CHAR, to-string AS CHAR
|
CHARACTER — The source string with every occurrence of the from-string replaced by the to-string.
|
|
RIGHT-TRIM
|
|
CHARACTER — The input string with the trim-chars removed from the end of the string. The trim-chars argument is optional and defaults to all white space.
|
|
SUBSTRING
|
source AS CHAR, position AS INTEGER, length AS INTEGER, type AS CHARACTER
|
CHARACTER — The substring of the source string beginning at the position. The length is optional and specifies the (maximum) length to return. The default is the remaining length of the string starting at position. The type is also optional and has same values as for the LENGTH function.
|
|
TRIM
|
string AS CHAR. trim-chars AS CHAR
|
CHARACTER — The input string with the trim-chars removed from both the beginning and the end of the string. The trim-chars argument is optional and defaults to all white space.
|